package cn.sdormitory.component.bindValue.query.mapping;


import cn.sdormitory.common.utils.ContainerUtil;
import cn.sdormitory.component.bindValue.bean.info.BindInfo;
import cn.sdormitory.sys.service.SysUserService;
import com.google.common.collect.Table;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Component("userMappingQuery")
public class UserMappingQuery implements MappingQuery{

    @Resource
    private SysUserService userService;

    @Override
    public Map<String, String> getMapping(BindInfo bindInfo, List<String> variables, Table<String, String, String> params) {
        List<Long> ids = ContainerUtil.toIds(variables);
        Map<Long, String> mappings = userService.findUserIdAndNameMappings(ids);
        return ContainerUtil.toStrMap(mappings);
    }
}
